package kr.saeildamil.androidstudy_second2930;

import java.util.Random;

import android.app.Service;
import android.content.Intent;
import android.os.Binder;
import android.os.IBinder;
import android.util.Log;

public class Localservice extends Service {
	private final IBinder mBinder=new LocalBinder();
	private final Random mGen=new Random();
	
	class LocalBinder extends Binder{
		Localservice getLocalservice(){
			Log.d("LocalBinder", "getLocalservice()");
			return Localservice.this;
		}
	}
	
	@Override
	public IBinder onBind(Intent arg0) {
		return mBinder;
	}
	
	//Activity (클라이언크)가 호출하는 메소드
	public int getRandomNumber(){
		return mGen.nextInt(100);
	}

	@Override
	public void onCreate() {
		Log.d("Localservice", "onCreate()");
		super.onCreate();
	}

	@Override
	public void onDestroy() {
		Log.d("Localservice", "onDestroy()");
		super.onDestroy();
	}

	@Override
	public int onStartCommand(Intent intent, int flags, int startId) {
		Log.d("Localservice", "onStartCommand()");
		return super.onStartCommand(intent, flags, startId);
	}
	

}
